package my.convert.attribute.processor.impl;

import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;

import my.convert.attribute.processor.AttributeProcessor;

public class OtherReferenceTypeAttributeProcessor extends AttributeProcessor{

	@Override
	public Map<String, Class<?>> execute(Class<?> entityClazz, Map<String, Class<?>> mapper) {
		List<Field> fields = super.parseEntry(entityClazz);
		if (fields == null || fields.size() == 0 || mapper == null) return null;
		for (Field field : fields) {
			Class<?> fieldClazz = field.getType(); // 得到field的class及类型全路径
			if (!isJavaClass(fieldClazz) && !fieldClazz.isArray()) { // 如果是非java类型，即自定义的类型
				mapper.put(field.getName()+".", fieldClazz);
			}
		}
		return mapper;
	}
	private static boolean isJavaClass(Class<?> clz) {     
	    return clz != null && clz.getClassLoader() == null;     
	}  
}
